package com.example.demo.controller;

import com.example.demo.dao.TestDao;
import com.example.demo.entity.Test;
import com.example.demo.service.ByIdService;
import com.example.demo.service.FindAll;
import com.example.demo.service.TestService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Test)表控制层
 *
 * @author makejava
 * @since 2022-05-31 12:09:21
 */
@RestController
@RequestMapping("test")
public class TestController {
    /**
     * 服务对象
     */
    @Resource
    private TestService testService;
    @Resource
    private TestDao testDao;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
//    @GetMapping("aa")
//    public  Test aa(){
//        ByIdService byIdService=(id)->{
//
//        };
//        byIdService.queryById(id);
//    }

    @PostMapping("aa")
    public  Test aa(int id) {
        ByIdService byIdService = aid -> testDao.queryById(aid);
        return byIdService.queryById(id);
    }

    @GetMapping("findAll")
    public List<Test> findAll() {
        FindAll findAll =() -> testDao.findAll();
        return findAll.findAll();
    }

}